// $Id: GLOBAL.java 15 2009-01-12 17:40:53Z moyekj@yahoo.com $

package com.hme.tivo.videostream;

import java.io.File;
import java.awt.Color;
import java.util.Hashtable;
import java.util.Stack;

public class GLOBAL {
   public static String TITLE = "Video Streamer (v0.13)";
   public static String configFile = "config.ini";
   public static String sortOrder = "alphanumeric";
	public static Boolean DEBUG = false;
	public static String BACKGROUND_PICTURE = "blue.jpg";
   public static String[] extList = {".mpg", ".vob", ".mpeg2", ".mp2", ".mp4", ".mpeg4"};
	public static String FOLDER_PREFIX = "__folder__";
	public static String FONT_SIZE = "medium";
   public static String bookmarkFile = "bookmarks";
   public static String ffmpeg = "";

   // Playback related globals
	public static Hashtable<String,String> topDirName;
   public static String streamFile;
   public static CountInputStream cstream;
   public static Hashtable<String,Long> positions;
   public static Hashtable<Long,Long> time2byte;
   public static Boolean Resume = false;
   public static Stack<String> playList = new Stack<String>();
   public static int playList_index = -1;
   public static Boolean playList_lock = false;
	
	// Colors
	public static Color title_COLOR = Color.yellow;
   public static Color text_COLOR = Color.white;
   public static Color text_SHADOW = Color.black;
   
   // Playback times
   public static int timeout_status_bar = 5;
   public static int timeout_info = 10;
   public static int skip_back = 8;
   public static int skip_forwards = 30;
   public static float slow_speed = (float)0.125;
		
	// list text relative positions
	public static int text_X = 25;
	public static int text_Y = 4;
	
	// folder icon
	public static String icon_PICTURE = "folder.png";
	public static int icon_X = 0;
	public static int icon_Y = 4;
	public static int icon_W = 24;
	
	// status bar
	public static int statusBG_W = 376;
	public static int statusBG_H = 15;
	public static int statusBG_X = (640-statusBG_W)/2;
	public static int statusBG_Y = 400;
	public static Color statusBG_COLOR = Color.black;
	public static String status_FONT = "default-18.font";
	public static Color statusBAR_COLOR = Color.green;
	
	public GLOBAL() {
	   // Set DEBUG variable if environment variable is set
	   if (System.getenv("DEBUG") != null) {
	      DEBUG = true;
	   }
	}

   public String makeFileName(String name) {
      debug.print("name=" + name);
      if ( name == null)
         return "";
      return name.replaceFirst(GLOBAL.FOLDER_PREFIX, "");
   }

   public String makeEntryName(String DIR, String name) {
      debug.print("DIR=" + DIR + " name=" + name);
      File d = new File(DIR + File.separator + name);
      if (d.isDirectory()) {
         return GLOBAL.FOLDER_PREFIX + name;
      }
    	return name;
   }
}
